/*
*Copyright 2011-2020 enniu.com
*/
<#if localPackage?? && localPackage!="">
package ${localPackage}.controller
</#if>


/**
* ${model.description}
* @author ${author} ${date}
* <#if email?? && email!="">E-mail:${email}</#if>
*/
@Controller
public class ${controller} extends BaseController {

      private static final String INDEX_TEMPLATE = "${controllerPath}/index";


      @RequestMapping(value = "/${controllerPath}/index.htm", method = RequestMethod.GET)
      public ModelAndView index(HttpServletRequest request,HttpServletResponse response,
          @RequestParam(defaultValue = "1" required = true, value = "page")int page,
          ${XxxBean} ${xxxBean}){
          ModelAndView mav = new ModelAndView();
          mav.addObject("pageInfo",${xxxService}.getPageInfoDto(${xxxBean},page,10));
          mav.setViewName(INDEX_TEMPLATE);
          return mav;
      }

      /*
       *添加新数据
       */
      @RequestMapping(value ="/${controllerPath}/insert.do", method = RequestMethod.POST)
      @ResponseBody
      public JsonResultDto insert(HttpServletRequest request,${XxxBean} ${xxxBean}){
         ${xxxService}.add(${xxxBean});
         return  new JsonResultDto(true);
      }

      /*
       *删除数据
       */
      @RequestMapping(value ="/${controllerPath}/delete.do", method = RequestMethod.POST)
      @ResponseBody
      public JsonResultDto delete(HttpServletRequest request,
           @RequestParam(required = true, value = "${id}")${DataTypeAdapt.convert(model.keyProperty.clazzType)} ${id}){
         ${xxxService}.deleteBy${Id}(${id});
         return  new JsonResultDto(true);
      }

      /*
       *更新数据
       */
      @RequestMapping(value ="/${controllerPath}/update.do", method = RequestMethod.POST)
      @ResponseBody
      public JsonResultDto update(HttpServletRequest request,${XxxBean} ${xxxBean}){
         ${xxxService}.update(${xxxBean});
         return  new JsonResultDto(true);
      }

      /*
       *查询数据
       */
      @RequestMapping(value ="/${controllerPath}/get.do", method = RequestMethod.POST)
      @ResponseBody
      public JsonResultDto select(HttpServletRequest request,
      @RequestParam(required = true, value = "${id}")${DataTypeAdapt.convert(model.keyProperty.clazzType)} ${id}){
         ${xxxService}.getBy${Id}(${id});
         return  new JsonResultDto(true);
      }

      @Autowired ${XxxServiceImpl} ${xxxService};
}
